<?php

use think\migration\Migrator;
use think\migration\db\Column;

class CreateWithdrawRecordsTable extends Migrator
{
    /**
     * Change Method.
     *
     * Write your reversible migrations using this method.
     *
     * More information on writing migrations is available here:
     * http://docs.phinx.org/en/latest/migrations.html#the-abstractmigration-class
     *
     * The following commands can be used in this method and Phinx will
     * automatically reverse them when rolling back:
     *
     *    createTable
     *    renameTable
     *    addColumn
     *    renameColumn
     *    addIndex
     *    addForeignKey
     *
     * Remember to call "create()" or "update()" and NOT "save()" when working
     * with the Table class.
     */
    public function change()
    {
        $table = $this->table('withdraw_records', ['engine' => 'InnoDB', 'comment' => '用户提现记录表']);
        $table->addColumn('user_id', 'integer', ['comment' => '用户ID'])
            ->addColumn('amount', 'decimal', ['precision' => 10, 'scale' => 2, 'comment' => '提现金额'])
            ->addColumn('wechat_qrcode', 'string', ['limit' => 255, 'comment' => '微信收款码URL'])
            ->addColumn('status', 'integer', ['limit' => 1, 'default' => 0, 'comment' => '状态：0-待审核，1-已通过，2-已拒绝'])
            ->addColumn('remark', 'string', ['limit' => 255, 'null' => true, 'comment' => '备注信息'])
            ->addColumn('admin_id', 'integer', ['null' => true, 'comment' => '审核管理员ID'])
            ->addColumn('audit_time', 'datetime', ['null' => true, 'comment' => '审核时间'])
            ->addColumn('create_time', 'datetime', ['comment' => '创建时间'])
            ->addColumn('update_time', 'datetime', ['comment' => '更新时间'])
            ->addIndex('user_id')
            ->addIndex('status')
            ->create();
    }
} 